package com.utilities;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class SQLManager {

	public void getName(){
		String url = "jdbc:mysql://localhost:3306/pls";
		String user = "root";
		String password = "password";
		String driver = "com.mysql.jdbc.Driver";

		Connection conn = null;
		Statement stmt = null;
		SQLConnection sqlConn = new SQLConnection(url, user, password, driver);
		
		try {
			
			if(conn == null){
				conn =  sqlConn.getConnection();
				stmt = conn.createStatement();
			}
			
			ResultSet rs = stmt.executeQuery("Select seat_code, employee_id from seat");
	
		
			int i = 1;
			while (rs.next()) {
				System.out.println("Username["+ i + "]: " + rs.getString("seat_code") + " " + rs.getString("employee_id") );
				i++;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (stmt != null){
					stmt.close();
				}
				if (conn != null){
					conn.close();
				}
			} catch (Exception e2) {
				// TODO: handle exception
			}
		}
		
	}
}
